package com.ds.lens.data.service.dao.sql.provider;

import com.ds.lens.data.service.dao.entity.LensApplicationUserRelation;
import org.apache.ibatis.jdbc.SQL;

public class LensApplicationUserRelationSqlProvider {

    public String insertSelective(LensApplicationUserRelation record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lens_application_user_relation");

        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getApplicationId() != null) {
            sql.VALUES("application_id", "#{applicationId,jdbcType=BIGINT}");
        }

        if (record.getUserName() != null) {
            sql.VALUES("user_name", "#{userName,jdbcType=VARCHAR}");
        }

        if (record.getUserType() != null) {
            sql.VALUES("user_type", "#{userType,jdbcType=TINYINT}");
        }
        if (record.getApplicationRole() != null) {
            sql.VALUES("application_role", "#{applicationRole,jdbcType=TINYINT}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LensApplicationUserRelation record) {
        SQL sql = new SQL();
        sql.UPDATE("lens_application_user_relation");

        if (record.getApplicationId() != null) {
            sql.SET("application_id = #{applicationId,jdbcType=BIGINT}");
        }

        if (record.getUserName() != null) {
            sql.SET("user_name = #{userName,jdbcType=VARCHAR}");
        }

        if (record.getUserType() != null) {
            sql.SET("user_type = #{userType,jdbcType=TINYINT}");
        }
        if (record.getApplicationRole() != null) {
            sql.SET("application_role = #{applicationRole,jdbcType=TINYINT}");
        }

        sql.WHERE("id = #{id,jdbcType=BIGINT}");

        return sql.toString();
    }
}
